﻿<%@ Page Title="" Language="C#" MasterPageFile="~/pages/master/WebList.Master" AutoEventWireup="true"
    CodeBehind="FunctionList.aspx.cs" Inherits="BF.Web.pages.BaseSystem.FunctionManagement.FunctionList" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceJs" runat="server">
    <script src="../../../script/OpenQuery.js" type="text/javascript"></script>
    <link href="../../../css/icon.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .treePanlStyle
        {
            position: absolute;
            bottom: 0px;
            top: 0px;
            border: #99bbe8 1px solid;
            width: 220px;
            overflow: hidden;
        }
    </style>
    <%--操作处理--%>
    <script type="text/jscript">
        //定义选择节点的ID和类型position: absolute;
        var nodeParam

        function Refurbish() {
            __doPostBack('ctl00$ContentPlaceHtml$AspNetPager1', '');
        }

        //弹出新增窗口
        function OnAdd() {
            if (nodeParam == null) {
                Ext.MessageBox.show({
                    title: '提示',
                    msg: '请在系统功能模块选择一项!',
                    buttons: { ok: '确  定' },
                    icon: 'ext-mb-info'
                });
                return false;
            }
            winer.OpenWin(
            '新增系统功能模块',
             GetUrl(this) + 'FunctionEdit.aspx?ParentID=' + nodeParam.sKey + '&ParentType=' + nodeParam.iType + '&ParentLevel=' + nodeParam.iLevel,
             650, 300, false, this
             );
            return false;
        }

        function OnUpdate() {
            if ($("input[name*='chxKey']:checked").length == 0) {
                Ext.MessageBox.show({
                    title: '提示',
                    msg: '请选择需要修改的数据!',
                    buttons: { ok: '确  定' },
                    icon: 'ext-mb-info'
                });
                return false;
            }
            if ($("input[name*='chxKey']:checked").length > 1) {//只能选择一项的判断
                Ext.MessageBox.show({
                    title: '提示',
                    msg: '只能选择一条记录!',
                    buttons: { ok: '确  定' },
                    icon: 'ext-mb-info'
                });
                return false;
            }
            var values = $("input[name*='chxKey']:checked'").val();
            winer.OpenWin('修改系统功能模块', GetUrl(this) + 'FunctionEdit.aspx?ID=' + values, 650, 300, false, this);
            return false;
        }

        function OnDelete() {
            if ($("input[name*='chxKey']:checked").length == 0) {
                Ext.MessageBox.show({
                    title: '提示',
                    msg: '请选择需要删除的数据!',
                    buttons: { ok: '确  定' },
                    icon: 'ext-mb-info'
                });
                return false;
            }
            Ext.MessageBox.show({
                title: '提示',
                msg: '是否确认删除选中的记录？',
                buttons: { yes: '确  定', no: '取 消' },
                fn: function (result) {
                    if (result == "yes") {
                        __doPostBack("ctl00$ContentPlaceHtml$lbtnDelete", "");
                    }
                },
                icon: 'ext-mb-info'
            });
            return false;
        }

        function OnUp() {
            if ($("input[name*='chxKey']:checked").length == 0) {
                Ext.MessageBox.show({
                    title: '提示',
                    msg: '请选择需要向上的数据!',
                    buttons: { ok: '确  定' },
                    icon: 'ext-mb-info'
                });
                return false;
            }
            if ($("input[name*='chxKey']:checked").length > 1) {//只能选择一项的判断
                Ext.MessageBox.show({
                    title: '提示',
                    msg: '只能选择一条记录!',
                    buttons: { ok: '确  定' },
                    icon: 'ext-mb-info'
                });
                return false;
            }
            return true;
        }

        function OnDown() {
            if ($("input[name*='chxKey']:checked").length == 0) {
                Ext.MessageBox.show({
                    title: '提示',
                    msg: '请选择需要向下的数据!',
                    buttons: { ok: '确  定' },
                    icon: 'ext-mb-info'
                });
                return false;
            }
            if ($("input[name*='chxKey']:checked").length > 1) {//只能选择一项的判断
                Ext.MessageBox.show({
                    title: '提示',
                    msg: '只能选择一条记录!',
                    buttons: { ok: '确  定' },
                    icon: 'ext-mb-info'
                });
                return false;
            }
            return true;
        }

        function nodeClickEvent(node, nodeParam) {
            var btnAdd = Ext.get("ctl00_ContentPlaceHtml_btnAdd");
            var btnDelete = Ext.get("ctl00_ContentPlaceHtml_lbtnDelete");
            switch (nodeParam.iType) {
                case 1:
                    btnAdd.dom.disabled = false;
                    break;
                case 2:
                    btnAdd.dom.disabled = false;
                    break;
                case 3:
                    btnAdd.dom.disabled = true;
                    break;
                default:
            }
            this.nodeParam = nodeParam;
            Ext.get("<%=hidParentID.ClientID%>").dom.value = nodeParam.sKey;
            Ext.get("txtCurrentNodeName").dom.value = " " + nodeParam.sName;
            Refurbish();
        }
    </script>
    <%--树处理--%>
    <script type="text/javascript">
        function GetThis() {
            return this;
        }

        var mytree;
        Ext.onReady(function () {

            mytree = new Ext.tree.TreePanel({
                el: "container", //应用到的html元素id
                animate: true, //以动画形式伸展,收缩子节点
                title: "系统功能模块树",
                collapsible: false,
                titleCollapse: false,
                rootVisible: false, //是否显示根节点
                autoScroll: true,
                bodyBorder: false,
                border: false,
                layout: 'fit',
                lines: true, //节点之间连接的横竖线
                loader: new Ext.tree.TreeLoader({
                    dataUrl: "LoadTreeHandler.ashx?NodeID=Null",
                    listeners: {
                        "loadexception": function (loader, node, response) {
                            node.loaded = false;
                            node.reload.defer(10, node); //不停的加载，直到true
                        }
                    }
                })

            });
            var root = new Ext.tree.AsyncTreeNode({
                id: "root",
                text: "控制面板",
                expanded: true
            });

            mytree.setRootNode(root);
            mytree.render();
            mytree.syncSize();
            var tmp = Ext.get('container');

            tmp.dom.onresize = function () {
                mytree.syncSize();
                var tmp2;
                tmp2 = Ext.get('ctl00_ContentPlaceHtml_AspNetPager1');
                tmp2.setWidth(Ext.getBody().dom.clientWidth - 237);
            }

        });

    </script>
    <%--页面回帮--%>
    <script type="text/javascript">
        function ReloadTree() {
            var node = mytree.getNodeById(GetThis().nodeParam.sKey);
            node.attributes.children = false;
            mytree.loader.dataUrl = "LoadTreeHandler.ashx?NodeID=" + node.id;
            if (node.reload)
                node.reload();
            else {
                mytree.loader.load(node, function () {
                    node.expand(true, true);
                })
            }
        }

        Ext.onReady(function () {
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function () {
                ReloadTree();
                var tmp = Ext.get('ctl00_ContentPlaceHtml_AspNetPager1');
                tmp.dom.style.width = Ext.getBody().dom.clientWidth - 237;
            });
        });
    </script>
    <%--div大小控制--%>
    <script type="text/javascript">
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHtml" runat="server">
    <div id="container" class="treePanlStyle">
    </div>
    <table id="tabHead" border="0" style="position: absolute; left: 221px; top: 0px;
        width: 100%; right: 0px;" cellpadding="0" cellspacing="0" class="listtop" align="center">
        <tr>
            <td style="width: 220px">
                <div class="center">
                    &nbsp;&nbsp;所属模块:<input id="txtCurrentNodeName" type="text" readonly="readonly" /></div>
            </td>
            <td>
                <div class="btn01">
                    <asp:LinkButton ID="btnAdd" runat="server" OnClientClick="return OnAdd();" OnClick="btnAdd_Click1">
                            <span>
                                <img src="../../../images/table_add.png" alt="" border="0" /><div class="center">
                                    新增</div>
                            </span>
                    </asp:LinkButton>
                    <asp:LinkButton ID="btnUpdate" OnClientClick="return OnUpdate();" runat="server">
                            <span>
                                <img src="../../../images/table_edit.png" alt="" border="0" /><div class="center">
                                    修改</div>
                            </span>
                    </asp:LinkButton>
                    <asp:LinkButton ID="lbtnDelete" runat="server" OnClientClick="return OnDelete();"
                        OnClick="lbtnDelete_Click">
                            <span>
                                <img src="../../../images/table_delete.png" alt="" border="0" /><div class="center">删除</div>
                            </span>
                    </asp:LinkButton>
                    <asp:LinkButton ID="lbtnUp" runat="server" OnClientClick="return OnUp();" OnClick="lbtnUp_Click">
                            <span>
                                <img src="../../../images/arrow_up.png" alt="" border="0" /><div class="center">向上</div>
                            </span>
                    </asp:LinkButton>
                    <asp:LinkButton ID="lbtnDown" runat="server" OnClientClick="return OnDown();" OnClick="lbtnDown_Click">
                            <span>
                                <img src="../../../images/arrow_down.png" alt="" border="0" /><div class="center">向下</div>
                            </span>
                    </asp:LinkButton>
                </div>
            </td>
        </tr>
    </table>
    <div id="div_scroll_x" class="div_scroll" style="position: absolute; left: 224px;
        width: auto; right: 0px;">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <input id="hidParentID" type="hidden" runat="server" />
                <asp:Repeater ID="Repeater1" runat="server">
                    <HeaderTemplate>
                        <table id="tbList" border="0" width="100%" align="center" cellpadding="0" cellspacing="0"
                            class="list">
                            <thead>
                                <tr>
                                    <td align="center" style="width: 32px;">
                                        选择 </td>
                                    <td align="center" style="width: 160px;">
                                        名称 </td>
                                    <td align="center">
                                        页面路径或控件ID </td>
                                    <td align="center" style="width: 32px;">
                                        级别 </td>
                                    <td align="center" style="width: 32px;">
                                        类型 </td>
                                    <td align="center" style="width: 32px;">
                                        序号 </td>
                                    <td align="center" style="width: 60px;">
                                        有效标识 </td>
                                </tr>
                            </thead>
                            <tbody>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <tr>
                            <td align="center">
                                <input type="checkbox" name="chxKey" id="chxKey" runat="server" accesskey='<%#Eval("iSort")%>'
                                    value='<%#Eval("gKey")%>' />
                            </td>
                            <td align="left">
                                <div class="divnr-auto" title='<%#Eval("sName")%>'>
                                    <img src="http://extjs.com/s.gif" id="image1" style="width: 22px; height: 18px; background-repeat: no-repeat;
                                        background-position: center 50%; vertical-align: middle !important" class="<%#Eval("sIconCls")%>" /><%#Eval("sName")%></div>
                            </td>
                            <td align="left">
                                <div class="divnr-auto" title='<%#Eval("sPath")%>'>
                                    <%#Eval("sPath")%></div>
                            </td>
                            <td align="center">
                                <%#Eval("iLevel")%>&nbsp; </td>
                            <td align="center">
                                <img src="http://extjs.com/s.gif" id="Img1" style="width: 22px; height: 18px; background-repeat: no-repeat;
                                    background-position: center 50%; vertical-align: middle !important" class="<%# Eval("iType").ToString() == "1" ? "icon-folder" : Eval("iType").ToString() == "2" ? "icon-file" : "icon-button"%>" />
                            </td>
                            <td align="center">
                                <%#Eval("iSort")%>
                            </td>
                            <td align="center">
                                <%#((bool)(Eval("bFlag")) ==true)?"已启用":"已停用"%>&nbsp; </td>
                        </tr>
                    </ItemTemplate>
                    <FooterTemplate>
                        </tbody> </table>
                    </FooterTemplate>
                </asp:Repeater>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="AspNetPager1" EventName="PageChanged" />
                <asp:AsyncPostBackTrigger ControlID="lbtnDelete" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="lbtnUp" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="lbtnDown" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
    <div class="div_AspNetPager" style="position: absolute; left: 221px; width: auto;
        right: 0px;">
        <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <table border="0" width="100%" align="center" cellpadding="0" cellspacing="0" class="fengye">
                    <tr>
                        <td>
                            <webdiyer:AspNetPager ID="AspNetPager1" Style="border: 1px solid #FF0000" runat="server"
                                OnPageChanged="AspNetPager1_PageChanged" meta:resourcekey="AspNetPager1" PageSize="15" SkinID="AspNetPager">
                            </webdiyer:AspNetPager>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="lbtnDelete" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="lbtnUp" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="lbtnDown" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
</asp:Content>
